package com.sky.controller.admin;

import com.sky.mapper.UserMapper;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.OrderAdminService;
import com.sky.service.OrderService;
import com.sky.service.SetmealService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.LocalTime;

@RestController
@RequestMapping("/admin/workspace")
@Slf4j
public class WorkspaceController {
    @Autowired
    private OrderAdminService orderAdminService;
    @Autowired
    private SetmealService setmealService;
    @Autowired
    private DishService dishService;
    @Autowired
    private OrderService orderService;
    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData() {
        LocalDateTime start = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime end = LocalDateTime.now().with(LocalTime.MAX);
        BusinessDataVO businessDataVO=orderAdminService.getTurnoverByStatus(start,end);
        return Result.success(businessDataVO);
    }
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> overviewSetmeals() {
        SetmealOverViewVO count=setmealService.overviewSetmeals();
        return Result.success(count);
    }
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> overviewDishs() {
        DishOverViewVO count2=dishService.overviewDishs();
        return Result.success(count2);
    }
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> overviewOrders() {
        OrderOverViewVO count3=orderService.statistics();
        return Result.success(count3);
    }
}
